/*
 * Copyright © 2010 SenseForce.com.
 * The Software shall be used for Good, not Evil.
 */

package com.senseforce.classes;

import javax.microedition.lcdui.*;
import com.senseforce.midlets.ShortMessage;

/**
 *
 * @author jcccn
 * @site http://www.senseforce.com/
 */
public class MessageWelcomeForm extends Form implements CommandListener{

	private ShortMessage midlet;
	private Command exitCommand = new Command("Exit", Command.EXIT, 0);
	private Command msgCommand	= new Command("Message", Command.SCREEN, 0);
	
	private StringItem welcomeStringItem;
	private ImageItem welcomeImageItem;

	public MessageWelcomeForm(String title, ShortMessage midlet) {
		super(title);
		this.midlet = midlet;
		
		welcomeStringItem = new StringItem(null, "Welcome your coming...");
		append(welcomeStringItem);
		
		Image img = null;
		try {
			img = Image.createImage(MessageConfig.img_path_welcome);
		} catch (Exception e) {
		
		}
		welcomeImageItem = new ImageItem(null, img, ImageItem.LAYOUT_CENTER, null);
		append(welcomeImageItem);
		
		setCommandListener(this);
		addCommand(exitCommand);
		addCommand(msgCommand);
	}
	
	public void commandAction(Command c, Displayable d) {
		if(c == exitCommand) {
			try  {
				midlet.destroyApp(true);
			} catch (Exception e) {
			}
			midlet.notifyDestroyed();
		}
		else if(c == msgCommand) {
			midlet.changeFormWithType(MessageConfig.FORMTYPE_EDIT);
		}
	}

}
